//
//  myActiveMainBottomView.swift
//  LeDian
//
//  Created by 三秒文化 on 16/3/22.
//  Copyright © 2016年 51ledian. All rights reserved.
//

import UIKit

class LDMyActiveMainBottomView: UIView {

    
    var titleLab:UILabel?
    var titleDesc:UILabel?
    var actionBtn:UIButton?
    
    var titleParams = [String]() {
        
        didSet{
            
            if titleParams.count < 2 {
                return
            }
            
            updateContent()
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setDefaultContent()
        setupFrame()
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func updateContent() {
    
        titleLab!.text = titleParams[0]
        titleDesc!.text = titleParams[1]
        actionBtn!.setTitle(titleParams[2],forState:UIControlState.Normal)
    }
    
    func setDefaultContent() {
        
        titleLab = UILabel.setDetailsLab("每日签到", fontSize: 16, titleColor: LDFontColor.Black,Alignment: .Center)
    
        titleDesc = UILabel.setDetailsLab("10活跃度/次", fontSize: 14, titleColor: LDFontColor.LightGray,Alignment: NSTextAlignment.Center)
        
        actionBtn = UIButton.setDetailsBtn("签到", picName: nil, btnBackColor: LDGolbalColor.GreenAssist, titleColor: LDFontColor.White)
        
        addSubview(titleLab!)
        addSubview(titleDesc!)
        addSubview(actionBtn!)
        
    }
    func setupFrame() {
        
        titleLab?.snp_makeConstraints(closure: { (make) in
            make.top.equalTo(Margin_V*2)
            make.centerX.equalTo(self)
//            make.width.equalTo(100)
            make.height.equalTo(20)
        })
        
        titleDesc?.snp_makeConstraints(closure: { (make) in
            make.top.equalTo((titleLab?.snp_bottom)!).offset(Margin_V)
            make.centerX.equalTo(titleLab!)
//            make.width.equalTo(100)
            make.height.equalTo(20)
        })
        
        actionBtn?.snp_makeConstraints(closure: { (make) in
            make.top.equalTo((titleDesc?.snp_bottom)!).offset(Margin_V*1.5)
            make.centerX.equalTo(titleLab!)
            make.width.equalTo(80)
            make.height.equalTo(30)
        })
    }
}
